/*
    Michael Eng, mse2124
    This class takes in a geographical coordinate pair and stores it as an lat, long tuple.  If longitude is West, long is stored as a negative number.  If latitude is South, lat is stored as a negative number.
*/
public class XYCoordinate {
    private double lat;
    private double longi;
    /*
        Args: Latitude degrees, latitude minutes, latitude direction, longitude degrees, longitude minutes, longitude direction
    */
    public XYCoordinate(double latd, double latm, String latSign, double longd, double longm, String longSign) {
        if(Math.abs(lat) > 90.0 || Math.abs(longi) > 180.0) {
            throw new IllegalArgumentException();
        }
        this.lat = latd + (latm * 60.0 / 3600.0);
        this.longi = longd + (longm * 60.0 / 3600.0);
        if(latSign.equalsIgnoreCase("S")) {
            this.lat *= -1.0;
        }
        if(longSign.equalsIgnoreCase("W")) {
            this.longi *=-1.0;
        }
    }
    /*
        If you already have coordinates converted from DMS + direction to X, Y use this constructor to store them as a pair
    */
    public XYCoordinate(double lat, double longi) {
        if(Math.abs(lat) > 90.0 || Math.abs(longi) > 180.0) {
            throw new IllegalArgumentException();
        }
        this.lat = lat;
        this.longi = longi;
    }
    public double getLat() {
        return lat;
    }
    public double getLong() {
        return longi;
    }
    public String toString() {
        return new String(lat + ", " + longi);
    }
}
